<?php include_once("../common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once("detail-list-function.php"); ?>
<?php include_once("function.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php include_once('../modules/head.php'); ?>
<link href="asset/css/style.css" rel="stylesheet" type="text/css"/>




</head>




<body>

<div id="topbar">
<?php include '../modules/topbar.php'; ?>
</div>



<div id="container">
<!--Container端點01-->
<div id="maincontent" class="list">
<!--maincontent端點01-->



<div id="sidebar">
    <?php include '../modules/sidebar.php'; ?>
</div>


<div id="content">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend><h1><? echo $sys_title ?></h1></legend>
    </fieldset>





    <div class="select-box layui-form clearfix <? echo $system_part ?>">
        <form action="detail-list.php" >

            <div class="layui-form-item">
                <label class="layui-form-label">关键词</label>
                <div class="layui-input-block">
                    <input type="text"  name="select_keywords" placeholder="名称，型号" autocomplete="off" class="layui-input" value="<? echo $_REQUEST['select_keywords']?>" >
                </div>
            </div>

       <?php
	   $cat_result = mysql_query("select * from ".$table_Prefix."term where belong = '".$sys_part."' and interm = 'root' and publish = 1 ");


	   ?>
            <div class="layui-form-item search-term">
                <label class="layui-form-label">分类</label>
                <div class="layui-input-block">
                    <select name="cat_id">
                       <option value="0" <?php if($_REQUEST['cat_id'] == 0){ echo 'selected="selected"';}?> >请选择分类</option>
                       <?php

					   while ($cat = mysql_fetch_array($cat_result)) { //一级
					   ?>
                       <option value="<?php echo $cat['nid']?>" <?php if($_REQUEST['cat_id'] == $cat['nid']){ echo 'selected="selected"';}?>><?php echo $cat['name']?></option>
                       <?php

					   	$cat2_result = mysql_query("select * from ".$table_Prefix."term where belong = 'product' and interm = 'term1' and publish = 1 and term1 =  ".$cat['nid']);

							while ($cat2 = mysql_fetch_array($cat2_result)) { //二级
						?>
								<option value="<?php echo $cat2['nid']?>" <?php if($_REQUEST['cat_id'] == $cat2['nid']){ echo 'selected="selected"';}?>> - <?php echo $cat2['name']?></option>
					    <?php
								$cat3_result = mysql_query("select * from ".$table_Prefix."term where belong = 'product' and interm = 'term2' and publish = 1 and term2 =  ".$cat2['nid']);
                    	    	while ($cat3 = mysql_fetch_array($cat3_result)) { //三级
						?>
                        			<option value="<?php echo $cat3['nid']?>" <?php if($_REQUEST['cat_id'] == $cat3['nid']){ echo 'selected="selected"';}?>> - - <?php echo $cat3['name']?></option>
                        <?php
								}
							}
					   }
					   ?>

                    </select>
                </div>
            </div>

	   <?php
	   $brand_result = mysql_query("select * from ".$table_Prefix."term where belong = 'brand' and interm = 'root' and publish = 1 order by en_name asc ");
	   ?>
            <div class="layui-form-item search-brand">
                <label class="layui-form-label">品牌</label>
                <div class="layui-input-block">
                    <select name="brand_id" lay-search="">
                       <option value="0" <?php if($_REQUEST['brand_id'] == 0){ echo 'selected="selected"';}?>>请选择品牌</option>
                       <?php
					   while ($brand = mysql_fetch_array($brand_result)) { //一级
					   ?>
                           <option value="<?php echo $brand['nid']?>" <?php if($_REQUEST['brand_id'] == $brand['nid']){ echo 'selected="selected"';}?>>
                               <?php echo $brand['en_name']?> (<?php echo $brand['name']?>)
                           </option>
<!--                       --><?php
//					   	$brand2_result = mysql_query("select * from ".$table_Prefix."term where belong = 'brand' and interm = 'term1' and publish = 1 and term1 =  ".$brand['nid']);
//							while ($brand2 = mysql_fetch_array($brand2_result)) { //二级
//						?>
<!--                            <option value="--><?php //echo $brand2['nid']?><!--" --><?php //if($_REQUEST['brand_id'] == $brand2['nid']){ echo 'selected="selected"';}?><!-->-->
<!--                                - --><?php //echo $brand2['name']?>
<!--                            </option>-->
<!---->
<!--					    --><?php
//                            $brand3_result = mysql_query("select * from ".$table_Prefix."term where belong = 'brand' and interm = 'term2' and publish = 1 and term2 =  ".$brand2['nid']);
//                            while ($brand3 = mysql_fetch_array($brand3_result)) { //三级
//						?>
<!--                        	<option value="--><?php //echo $brand3['nid']?><!--" --><?php //if($_REQUEST['brand_id'] == $brand3['nid']){ echo 'selected="selected"';}?><!-->-->
<!--                                - - --><?php //echo $brand3['name']?>
<!--                            </option>-->
<!--                        --><?php
//								}
//							}
					   }
					   ?>

                    </select>
                </div>
            </div>

			<input type="hidden"  name="sys_part"  value="<?php echo $system_part;?>"/>
            <button class="layui-btn" ><i class="layui-icon">&#xe615;</i> 查找</button>

            <button class="layui-btn" type="reset" ><i class="layui-icon">&#x1006;</i> 重置</button>

            <br class="clearfloat"/>
        </form>

        <br class="clearfloat"/>
    </div>



 <!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
<div class="list-box clearfix <? echo $system_part ?>">

        <hr/>
        <div class="statistic">

            <?php include_once("../modules/detail_btn.php");?>

			<a class="layui-btn all_qcode" style="display:none;" href="erweima_all_list.php?nav-itemed=unit&sys_part=<?php echo $system_part?>"><i class="layui-icon">&#xe64a;</i>  二维码批量生成</a>

            <div class="function">

                <div class="sort layui-form">
                    <div class="layui-form-item" style="margin-bottom:5px;">
                        <label class="layui-form-label">排序：</label>
                        <div class="layui-input-block">
                            <select lay-filter="MM_jumpMenu" >
    <option <?php if($sortby == ''){echo 'selected="selected"';}?>  value="detail-list.php?nowpageid=<?php echo $nowpageid; ?>&nid=<? echo $trans_nid ?>&sortby=listorder&sys_part=<? echo $system_part ?>">排序选择</option>
    <option <?php if($sortby == 'listorder' && $sortorder == 'desc'){echo 'selected="selected"';}?> value="detail-list.php?nowpageid=<?php echo $nowpageid; ?>&nid=<? echo $trans_nid ?>&sortby=listorder&sortorder=desc&sys_part=<? echo $system_part ?>">人工排序降序</option>
    <option <?php if($sortby == 'listorder' && $sortorder == 'asc'){echo 'selected="selected"';}?> value="detail-list.php?nowpageid=<?php echo $nowpageid; ?>&nid=<? echo $trans_nid ?>&sortby=listorder&sortorder=asc&sys_part=<? echo $system_part ?>">人工排序升序</option>
    <option <?php if($sortby == 'nid' && $sortorder == 'desc'){echo 'selected="selected"';}?> value="detail-list.php?nowpageid=<?php echo $nowpageid; ?>&nid=<? echo $trans_nid ?>&sortby=nid&sortorder=desc&sys_part=<? echo $system_part ?>">输入时间降序</option>
    <option <?php if($sortby == 'nid' && $sortorder == 'asc'){echo 'selected="selected"';}?> value="detail-list.php?nowpageid=<?php echo $nowpageid; ?>&nid=<? echo $trans_nid ?>&sortby=nid&sortorder=asc&sys_part=<? echo $system_part ?>">输入时间升序</option>
    <option <?php if($sortby == 'name' && $sortorder == 'desc'){echo 'selected="selected"';}?> value="detail-list.php?nowpageid=<?php echo $nowpageid; ?>&nid=<? echo $trans_nid ?>&sortby=name&sortorder=desc&sys_part=<? echo $system_part ?>">资料名称升序</option>
    <option <?php if($sortby == 'name' && $sortorder == 'asc'){echo 'selected="selected"';}?> value="detail-list.php?nowpageid=<?php echo $nowpageid; ?>&nid=<? echo $trans_nid ?>&sortby=name&sortorder=asc&sys_part=<? echo $system_part ?>">资料名称降序</option>
</select>
                        </div>
                    </div>
                </div>


            </div>


            <hr/>
        </div>



<div class="list-boxes">



    <table class="layui-table layui-form">
        <colgroup>
            <col width="20">
            <col width="100" class="icon">
            <col>
            <col width="175">
            <col width="145" class="status">
            <col width="100" class="publish">
            <col width="300">
        </colgroup>
        <thead>
        <tr>
            <th> </th>
            <th class="icon">图片</th>
            <th>资料</th>
            <th>排序</th>
            <th class="status">状态</th>
            <th class="publish">发布</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <?php for ($i = 0; $i < count($detail_nid); $i++) {
        ?>

        <tr id="item<?echo $detail_nid[$i]?>">
            <td >
                 <input type="checkbox" name="nid[]"
                        value="<?echo $detail_nid[$i]?>"
                        lay-skin="primary"
                        lay-filter="nid-filter"
                 >
<!--                 <span>--><?//echo $i+1?><!--</span>-->
            </td>

            <td class="icon"><img src="<? if ($detail_storage[$i]) { echo $detail_storage[$i]; } else { echo $site_domin; } ?>/uploadfiles/<? echo $theme_folder ?>/<?php echo $detail_icon[$i] ?>" /></td>
            <td> <ul class="list-boxing-data">
                    <li class="title-name">
                        <h6 style="font-size: 18px"><label>名称：</label>
                        <a href="detail-edit.php?nid=<?php echo $detail_nid[$i] ?>&sys_part=<? echo $system_part ?>" <? if ($detail_publish[$i] != 1) { echo "class='title-notice'"; } ?>  style="font-size:14px; "><?php echo $detail_name[$i] ?></a>
                        </h6>
                    </li>


                    <li class="list-boxing-content">
                        <label>简介：</label>

                        <?
						$now_detail_introduce = cleanhtml($detail_introduce[$i]);
                        if (strlen($now_detail_introduce) > 150) {
                            echo utf8Substr($now_detail_introduce, 0, 50) . "...";
                        } else if (strlen($now_detail_introduce) == 0) {
                            echo "暂无资料";
                        } else {
                            echo $now_detail_introduce;
                        }
                        ?>

                    </li>

                    <br class="clearfloat"/>

 					<li class="brand">
                        <label style="float:left;line-height:28px;">所属品牌：</label>
                        <div style=" float:left; line-height:28px;">
                        <?php

                        $cat_list = gettermdate_brand($detail_nid[$i]) ;

						if($cat_list){

							foreach($cat_list as $val){

								$msg = '根目录' ;

								foreach($val as $val1){
									$msg .= ' \ '.$val1 ;
								}
								$msg .= '<br>' ;
								echo $msg;
							}

						}
						else{
							echo '根目录 \ ' ;
						}

                       ?>
                       </div>
                    </li>
                    <br class="clearfloat"/>
                    <li class="term">
                        <label style="float:left;line-height:28px;">所属分类：</label>
                        <div style=" float:left; line-height:28px;">
                        <?php

                        $term_list[]="";
                        //通过 $detail_nid[$i] 查询出上级分类 （只有一级分类没有使用递归查询）
                        $termResult = mysql_query(" SELECT (SELECT name FROM evo_term WHERE nid =  t.term1 ) AS parentname,t.name AS subname".
                            " FROM evo_detail d".
                            " INNER JOIN evo_relation r ON r.detail_nid = d.nid".
                            " INNER JOIN evo_term  t ON t.nid = r.term_nid".
                            " WHERE r.belong IS NULL AND d.nid = '$detail_nid[$i]' " );

                        $term_list = array();
                        while ($row = mysql_fetch_assoc($termResult)) {
                            $term_list[] = $row;
                        }

//                                                $cat_list = gettermdate($detail_nid[$i]) ;



						if($term_list){

							foreach($term_list as $val){

							    //to do 这里暂时只支持到一级分类。后期整个取代，更换到controller中获取结果

								$msg = '根目录' ;

								foreach($val as $val1){
									$msg .= ' \ '.$val1 ;
								}
								$msg .= '<br>' ;
								echo $msg;
							}

						}
						else{
							echo '根目录 \ ' ;
						}

                       ?>
                       </div>
                    </li>







                </ul>
            </td>




            <!--排序-->
            <td class="status">
                <li class="markorder bind-markorder">

                    <div class="addsub">
                        <div class="title">标记顺序</div>
                        <button type="button" class="btn-add">
                            +
                        </button>
                        <input type="text" data-id="<?echo $detail_nid[$i]?>"  class="input-counter" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $detail_markorder[$i] ?>">
                        <button type="button" class="btn-subtract">
                            -
                        </button>
                    </div>

                </li>
                <li class="listorder bind-listorder">
                    <div class="addsub">
                        <div class="title">列表顺序</div>
                        <button type="button" class="btn-add">
                            +
                        </button>
                        <input type="text" data-id="<?echo $detail_nid[$i]?>"   class="input-counter" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $detail_listorder[$i] ?>">
                        <button type="button" class="btn-subtract">
                            -
                        </button>
                    </div>


                </li>
                <li class="termorder bind-termorder">
                    <div class="addsub">
                        <div class="title">分类顺序</div>
                        <button type="button" class="btn-add">
                            +
                        </button>
                        <input type="text" data-id="<?echo $detail_nid[$i]?>"  class="input-counter" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $termorder[$i] ?>">
                        <button type="button" class="btn-subtract">
                            -
                        </button>
                    </div>
                </li>
            </td>





            <td>
                <ul>
                    <?php
                    if ($product_price_show == 1) {
                        ?>
                        <li class="price">
                            <label>价格：</label>￥<? echo $detail_price[$i] ?>
                        </li>
                        <?php
                    }
                    ?>




                    <li class="recommend">
                        <label>推荐状态</label>
                        <input type="checkbox" name="recommend" value="<?php echo $detail_recommend[$i];?>"
                               lay-skin="switch" lay-filter="filter"
                               id="<?php echo $detail_nid[$i];?>"
                               lay-text="是|否" <?if ($detail_recommend[$i] == 1) { echo "checked"; }?> >
                    </li>

                    <li class="hotsale" style="display:none">
                            <label>热销状态</label>
                        <input type="checkbox" name="hotsale" value="<?php echo $detail_hotsale[$i];?>"
                               lay-skin="switch" lay-filter="filter"
                               id="<?php echo $detail_nid[$i];?>"
                               lay-text="是|否" <?if ($detail_hotsale[$i] == 1) { echo "checked"; }?> >
                    </li>

                    <li class="mark">
                            <label>标记状态</label>
                        <input type="checkbox" name="mark" value="<?php echo $detail_mark[$i];?>"
                               lay-skin="switch" lay-filter="filter"
                               id="<?php echo $detail_nid[$i];?>"
                               lay-text="是|否" <?if ($detail_mark[$i] == 1) { echo "checked"; }?> >
                    </li>



                <!--                    <li class="clickrate">-->
                <!--                        <label>点击次数：</label>--><?// echo $detail_clickrate[$i] ?>
                <!--                    </li>-->

                <!--                    <li class="inputtime">-->
                <!--                        <label>输入时间：</label>--><?// echo $detail_inputtime[$i] ?>
                <!--                    </li>-->
                <!--                    <li class="modifytime">-->
                <!--                        <label>修改时间：</label>--><?// echo $detail_modifytime[$i] ?>
                <!--                    </li>-->


                <!--<li class="model">-->
                <!--<label> 型号：</label>--><?// echo $detail_model[$i] ?>
                <!--</li>-->




                <!--            <li class="discount">-->
                <!--                <label>折扣状态：</label>--><?//if ($detail_discount[$i] == 1) { echo "是"; } else { echo "否"; }?>
                <!--            </li>-->

                <!--            <li class="soldout">-->
                <!--                <label>下架状态：</label>--><?//if ($detail_soldout[$i] == 1) { echo "是"; } else { echo "否"; }?>
                <!--            </li>-->
                <!--            <li class="onsaletime">-->
                <!--                <label>上架时间：</label>--><?// echo $detail_onsaletime[$i] ?>
                <!--            </li>-->

                </ul>
            </td>




            <td class="publish">
                <li >
                    <input type="checkbox" name="publish" value="<?php echo $detail_publish[$i];?>"
                           lay-skin="switch" lay-filter="filter"
                           id="<?php echo $detail_nid[$i];?>"
                           lay-text="发布|隐藏" <?if ($detail_publish[$i] == 1) { echo "checked"; }?> >
                </li>

            </td>





<td>



<div style="margin-bottom:15px;border-bottom: solid 1px #cccccc;padding-bottom: 15px; ">

<!-- <a href="javascript:void(0)"  class="delete layui-btn  layui-btn-sm" <?php if($detail_is_disabled[$i] == 1){echo 'style= background:#ccc;cursor:not-allowed;';}else{ echo 'onclick="popupBox('. $detail_nid[$i].' )"';}?> > <i class="layui-icon">&#xe640;</i> 删除</a> -->
<a href="javascript:void(0)"  class="delete layui-btn  layui-btn-sm" <?php if($detail_is_disabled[$i] == 1){echo 'style= background:#ccc;cursor:not-allowed;';}else{ echo 'onclick="delItem('. $detail_nid[$i].' )"';}?> > <i class="layui-icon">&#xe640;</i> 删除</a>
<a href="detail-edit.php?nid=<?php echo $detail_nid[$i] ?>&sys_part=<? echo $system_part ?>&nowpageid=<? echo $_REQUEST['nowpageid'] ?>&brand_id=<? echo $_REQUEST['brand_id'] ?>&sortby=<? echo $_REQUEST['sortby'] ?>&term_nid=<? echo $trans_nid ?>" class="modify layui-btn  layui-btn-sm" > <i class="layui-icon">&#xe642;</i> 修改</a>
<a class="weixin-miniapp-code layui-btn  layui-btn-sm" onclick="getWXCode(this)" data-nid="<?php echo $detail_nid[$i] ?>" data-name="<?php echo $detail_name[$i] ?>"> <i class="layui-icon">&#xe677;</i> 小程序码</a>
<a href="/<? echo $detail_url[$i] ?>.html" target="_blank" class="preview layui-btn  layui-btn-sm" > <i class="layui-icon">&#xe621;</i> 预览</a>
<input type="button" class="layui-btn  layui-btn-sm huanqiao-sync-detail" data-nid="<?php echo $detail_nid[$i] ?>" value="同步此产品">
</div>




<a href="../threeD/detail-show-function.php?nid=<?php echo $detail_nid[$i] ?>" class="threeDbtn layui-btn  layui-btn-sm">3D展示</a>

<a href="erweima.php?nid=<?php echo $detail_nid[$i] ?>&sys_part=<? echo $system_part ?>" class="threeDbtn layui-btn  layui-btn-sm">二维码设置</a>
</td>



        </tr>
            <?php

        }
        ?>
        </tbody>
    </table>




</div>





</div>




<hr/>

 <?php include_once(ROOT_PATH_."/controller/modules/page.php"); ?>



<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>
<!--删除box-->
<?php include '../modules/deletebar.php'; ?>
<!--删除box end-->

<?php include  ROOT_PATH_."/controller/modules/footer.php"; ?>

<script charset="utf-8" src="asset/js/select_order_jump.js?version=20231021"></script>










<script>
    function getWXCode(e) {
        const nid = e.dataset.nid
        const name = e.dataset.name
        const domain = 'https://dj100.enpingshi.com/'
        $.ajax({
            method: 'GET',
            url: domain + 'api/dangjian100/get_qc_code.php',
            data: {
                path: '/pages/place-audio-brief/place-audio-brief',
                name,
                nid
            },
            contentType: 'application/json',
            success: res => {
                const obj = JSON.parse(res)
                if(obj.code == 0) {
                    window.open(domain + obj.data)
                }
            }
        })
    }







    function updateSort(id,ainame,sum){
        if(sum == ''){
            return false
        }
        let param = {'nid':id,'ai_name': ainame,'sum': sum}
        var loading2 = layer.open({ type: 3, shade: [0.25, '#000'], icon: 2, speed: 0});
        $.get('controller/update_col.php',param,function(data,status){
            layer.close(loading2);
        });
    }


</script>




</body>
</html>
